POV-Ray : Newsgroups : povray.advanced-users : Beeing stupid... y=x*sin(1/x), how to? : Re: Beeing stupid... y=x*sin(1/x), how to? Server Time
2 Nov 2024 09:19:13 EDT (-0400)
  Re: Beeing stupid... y=x*sin(1/x), how to?  
From: Chris Huff
Date: 15 Dec 1999 15:30:54
Message: <chrishuff_99-E0211D.15312415121999@news.povray.org>
In article <MPG.12c18e98202e9328989683@news.povray.org>, Mario Splivalo 
<msp### [at] jagorsrcehr> wrote:

> Anyone, please, i'd love to plot a graph of the function, well, it's like 
> this:
> 
> I have y = x * sin(1/x), and its some graph in 2D, Well, now i want to 
> rotate that graph around the z-axe (one pointing up/down), and represent 
> that in POV. Is that possible withouht 3rd party programs/utils?

If you mean you want to make a kind of lathe, swept around the z axis, 
it would be pretty simple to do. One way would be to use an isosurface, 
with a function like:
function {z - sqrt(x^2 + y^2)*sin(1/sqrt(x^2 + y^2))}
replacing x with sqrt(x^2 + y^2), which is the distance from the z axis.

Another way would be to use an actual lathe object, and use a #while 
loop to calculate the position of each control point.

Or if you want to represent the actual graph in POV, not making a 3D 
graph, you can use an image_map to use a picture of the graph for the 
texture, or you can create it out of objects, something like 
this(untested!):

#macro GetValAt(V)
    (V*sin(1/V))
#end
#macro MakeGraph(Elems, XSize, graphRadius, graphTexture)
    #local stPos = < 0, 0, 0>;
    sphere {stPos, graphRadius
        texture {graphTexture}
    }
    #local K=0;
    #while(K<Elems)
        #local endPos = <(K/(Elems - 1))*XSize, GetValAt((K/(Elems - 
1))*XSize), 0>;
        cylinder {stPos, endPos, graphRadius
            texture {graphTexture}
        }
        sphere {endPos, graphRadius
            texture {graphTexture}
        }
        #local stPos = endPos;
        #local K=K+1;
    #end
#end

This macro would be used like this:
MakeGraph(50, 5, 0.05, MyTexture)

Where:
Elems = the number of elements in the graph
XSize = the distance along the x axis the graph extends
graphRadius = the radius of the graph elements
graphTexture = the texture of the graph elements

-- 
Chris Huff
e-mail: chr### [at] yahoocom
Web page: http://chrishuff.dhs.org/


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.